export default {
  created() {
    // permission adapter
    const permissions = ['query'];
    for (const pagePermission of this.pagePermissions) {
      // const defaultPermission = ['batch', 'query', 'add', 'delete', 'edit', 'insert', 'export', 'import'];

      switch (pagePermission) {
        case 'Add':
          permissions.push('add');
          break;
        case 'Del':
          permissions.push('delete');
          break;
        case 'DelList':
          permissions.push('batch');
          break;
        case 'Update':
          permissions.push('edit');
          break;
        default:
          permissions.push(pagePermission);
          break;
      }
    }
    this.$permissions = permissions;
  },
  computed: {
    // calculate the table actions column with base on permissions
    baseActionsColumnWidth() {
      let width = 0;
      const unit = 95;
      if (this.$permissions.includes('delete')) {
        width += unit;
      }
      // if (this.$permissions.includes('edit')) {
      //   width += unit;
      // }
      return width;
    }
  },
  data() {
    return {
      $permissions: [], // table permissions
      pagePermissions: window.pagePermissions || [
        'Add',
        'Del',
        'Generate',
        'BAudit',
        'FAudit',
        'Enable',
        'Update',
        'export'
      ]
    };
  }
};
